﻿// -----------------------------------------------------------------------
// <copyright file="AnimalBase.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Cspl.AnimalFight.Lib.Data
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public abstract class AnimalBase
    {
        #region Field
        protected string _animalName;
        protected int _healthPower;
        protected int _defensePower;
        protected int _attackPower;
        protected bool _hasEscaped;
        protected bool _isDead;
        #endregion

        #region Property
        public bool HasEscaped
        {
            get { return _hasEscaped; }
            set { _hasEscaped = value; }
        }

        public bool IsDead
        {
            get { return _isDead; }
            set { _isDead = value; }
        }

        public string Name
        {
            get { return _animalName; }
            set { _animalName = value; }
        }

        public int HP
        {
            get { return _healthPower; }
            set 
            {
                _healthPower = value;
            }
        }

        public int DP
        {
            get { return _defensePower; }
            set 
            { 
                _defensePower = value;
            }
        }

        public int AP
        {
            get { return _attackPower; }
            set 
            { 
                _attackPower = value;
            }
        }
        #endregion

        #region Method
        public virtual void Escape()
        {
            this.HasEscaped = true;
            Console.WriteLine("The Animal Escaped.");
        }

        public bool IsExistOnBattleField(string command)
        {
            if (IsDead)
            {
                Console.Write("The {0} is already ", this.Name);
                Console.BackgroundColor = ConsoleColor.Red;
                Console.Write("dead");
                Console.ResetColor();
                Console.WriteLine(". Cannot commence {0}", command);
                Console.WriteLine();
            }
            else if (HasEscaped)
            {
                Console.Write("The {0} is already ", this.Name);
                Console.BackgroundColor = ConsoleColor.Red;
                Console.Write("escaped");
                Console.ResetColor();
                Console.WriteLine(". Cannot commence {0}", command);
                Console.WriteLine();
            }
            else
            {
                return true;
            }
            return false;
        }
        #endregion
    }
}
